home *** CD-ROM | disk | FTP | other *** search
- Path: rcp6.elan.af.mil!rscernix!danpop
- From: danpop@mail.cern.ch (Dan Pop)
- Newsgroups: comp.lang.c
- Subject: Re: int main() vs int main(void)
- Date: 8 Feb 96 20:19:07 GMT
- Organization: CERN European Lab for Particle Physics
- Message-ID: <danpop.823810747@rscernix>
- References: <1996Feb7.201848.18734@atlas.tntech.edu> <4fde76$flj@sam.inforamp.net>
- NNTP-Posting-Host: ues5.cern.ch
- X-Newsreader: NN version 6.5.0 #7 (NOV)
-
- In <4fde76$flj@sam.inforamp.net> rmorin@inforamp.net (Randy Charles Morin) writes:
-
- >My understanding is that in C++, there is absolutely no difference. But in C,
- >there is a slight difference. I think the proper example is the following...
- >
- >void f(void);
- >void f(){};
- >
- >This two line program is the key.
-
- This is by no means a C program. Why?
-
- >It compile in C++ and doesn't in C.
-
- The only reason it may not compile in C is because it contains an empty
- declaration (can you see it?).
-
- Otherwise it is a legal C translation unit and it does compile (after
- removing the empty declaration):
-
- ues5:~/tmp 25> cat test.c
- void f(void);
- void f(){}
- ues5:~/tmp 26> cc -c test.c
- ues5:~/tmp 27> c89 -c test.c
- ues5:~/tmp 28> gcc -pedantic -c test.c
- ues5:~/tmp 29>
-
- >You have to change the program to...
- >
- >void f(void);
- >void f(void){};
- >
- >..for it to compile in C.
-
- This one is just as broken as the first one and just as correct after
- the empty declaration is removed.
-
- >But, I'm not an expert on the subject.
-
- A very good reason to keep your mouth shut, in order to avoid confusing
- other people with your misconceptions.
-
- >So, I'd confirm this by compiling the programs yourself.
-
- It's better to search the confirmation in books, not in compilers.
-
- >No other differences exist in my books.
-
- If there is any difference between your examples in your books, then those
- books are not about the C programming language.
-
- Dan
- --
- Dan Pop
- CERN, CN Division
- Email: danpop@mail.cern.ch
- Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
-